home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Perl Multimedia Cyber Classroom
/
PERL Multimedia Cyber Classroom (Prentice Hall)(1998).ISO
/
perlbyex
/
code.jar
/
08ex006.jar
/
code
/
ch08
/
08ex006
/
08ex006.pl
next >
Wrap
Perl Script
|
1998-04-01
|
613b
|
22 lines
#!/usr/bin/perl
$friend = Louise; # global variables
$pal = Danny;
print "$friend and $pal are global.\n" ;
sub guests {
my ($friend)= "Pat" ; # $friend is known only in this function
local $pal= "Chris" ; # $pal is known in this function and functions
# called from here
print "In guests subroutine:
$friend and $pal are welcome guests.\n" ;
&who_is_it; # call subroutine
}
sub who_is_it {
print "In who_is_it subroutine:
You still have your global friend, $friend, here.\n" ;
print "But your pal is now $pal.\n" ; # $pal can be changed here
}
&guests; #call subroutine